package couk.mmtdigital.sm.view
{
	import couk.mmtdigital.sm.ApplicationFacade;
	import couk.mmtdigital.sm.view.components.AddFileView;
	
	import flash.net.FileReference;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class AddFileViewMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "AddFileViewMediator";
				
		public function AddFileViewMediator(vc:Object=null)
		{
			super(NAME, vc);
		}
		
		override public function listNotificationInterests():Array{
			return [
				ApplicationFacade.NEWFILE,
				ApplicationFacade.NEWFOLDER
			];
		}
		
		override public function handleNotification(notification:INotification):void{
			switch(notification.getName()){
				case ApplicationFacade.NEWFILE:
					var file:FileReference = notification.getBody() as FileReference;
					trace("note file name: "+file.name);
					addFileView.fudg.dataProvider = file;
					break;
				case ApplicationFacade.NEWFOLDER:
					break;
			}
		}
		
		private function get addFileView():AddFileView{
			return viewComponent as AddFileView;
		}
	}
}